package com.dx.bs.domain.r;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {
    // 响应码
    private Integer code;

    // 响应信息
    private String message;

    // 响应数据
    private T data;


    public static<T> R<T> success(String message)
    {
        return new R<>(200, message, null);
    }


    public static<T> R<T> success(String message, T data)
    {
        return new R<>(200, message, data);
    }
    public static<T> R<T> error(String message)
    {
        return new R<>(400, message, null);
    }
    public static<T> R<T> error(Integer code, String message)
    {
        return new R<>(code, message, null);
    }
}
